package org.csu.mypetstore.service.impl;

import org.csu.mypetstore.domain.Sentence;
import org.csu.mypetstore.persistence.TalkMapper;
import org.csu.mypetstore.service.TalkService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class TalkServiceImpl implements TalkService {
    @Autowired
    private TalkMapper talkMapper;

    @Override
    public List<Sentence> getTalkList(String username) {
        return talkMapper.getTalkList(username);
    }

    @Override
    public List<String> getNameList() {
        return talkMapper.getNameList();
    }

    @Override
    public String insertSentence(Sentence sentence) {
        try{
            talkMapper.insertSentence(sentence);
            return "发送成功!";
        }catch (Exception e)
        {
            e.printStackTrace();
            return  "发送失败!";
        }
    }

    @Override
    public int getLength(String username) {
        return talkMapper.getLength(username);
    }

    @Override
    public int getLengthAdmin() {
        return talkMapper.getLengthAdmin();
    }
}
